var db = require('../../models/service');
var extend = require('util')._extend;
var moment = require('moment');
var result = {};
/*
服务列表
 */
exports.serviceList = function(req,res,next){


    var model = db.Service;
    
    db.sequelize.query("SELECT id, title, brief, attachment FROM service_service").spread(function (results, metadata) {
        
            for(i = 0; i < results.length; i++){
                results[i].attachment = "http://dunoinfo.com/medias/" + results[i].attachment;
            }

            result = results;

            return res.send(result);

    })
    .catch(function(error) {
            commonFuc.errorMsg(res,result,error);
    })

}

/*
服务类型
 */
 exports.serviceKind = function(req,res,next){

    var model = db.serviceKind;

    db.sequelize.query("SELECT id, name, code FROM service_servicekind").spread(function (results, metadata) {

            result = results;

            return res.send(result);

    })
    .catch(function(error) {
            commonFuc.errorMsg(res,result,error);
    })

 }